"""
在meiduo_admin应用的路由配置文件里，设置美多上传后台管理的路径映射
"""


from django.conf.urls import url
from .views.home_views import *
from .views.user_views import *
from .views.sku_views import *
from .views.spu_views import *
from .views.spec_views import *
from .views.option_views import *
from .views.image_views import *
from .views.order_views import *
from .views.perm_views import *
from .views.group_views import *
from .views.admin_views import *


# obtain_jwt_token: 是拓展插件提供的一个视图，功能是验证用户名和密码，签发返回token值
from rest_framework_jwt.views import obtain_jwt_token

urlpatterns = [
    # 登陆接口
    # obtain_jwt_token视图，默认只返回了新签发的token值
    # 但是我们的业务中要求，必须返回用户名和用户的id
    url('^authorizations/$', obtain_jwt_token),

    # 用户总数统计
    url(r'^statistical/total_count/$', UserTotalView.as_view()),
    # 日新增用户统计
    url(r'^statistical/day_increment/$', UserDayIncrView.as_view()),
    # 日活跃用户统计
    url(r'^statistical/day_active/$', UserActiveView.as_view()),
    # 日下单用户
    url(r'^statistical/day_orders/$', UserDayOrderView.as_view()),
    # 月新增用户数量
    url(r'^statistical/month_increment/$', UserMonthIncrView.as_view()),
    # 日分类商品访问量
    url(r'^statistical/goods_day_views/$', GoodsVisitCountView.as_view()),

    # 用户数据获取/新建
    url(r'^users/$', UserListCreateView.as_view()),

    # sku增删改查
    # GET + /skus/ = self.list 序列化返回多条数据
    # POST + /skus/ = self.create 反序列化新建单一
    url(r'^skus/$', SKUModeViewSet.as_view({'get': 'list', 'post': 'create'})),
    # DELETE + skus/(?P<pk>\d+)/ = self.destroy 删除单一对象
    # GET + skus/(?P<pk>\d+)/  = self.retrieve 序列化返回单一数据
    # PUT + skus/(?P<pk>\d+)/  = self.update 全更新单一数据
    url(r'^skus/(?P<pk>\d+)/$', SKUModeViewSet.as_view({'delete': 'destroy', 'get': 'retrieve', 'put': 'update'})),


    # 新建sku可选分类信息
    url(r'^skus/categories/$', GoodsCategoryView.as_view()),
    # 新建sku可选spu信息
    url(r'^goods/simple/$', SPUSimpleView.as_view()),
    # 新建sku选择的spu的可选规格和选项信息
    url(r'^goods/(?P<pk>\d+)/specs/$', SPUSpecOptionView.as_view()),

    # spu管理
    # GET + /goods/ = self.list
    # POST + /goods/ = self.create
    url(r'^goods/$', SPUModelViewSet.as_view({'get': 'list', 'post': 'create'})),
    # GET + /goods/(?P<pk>\d+)/ = self.retrieve
    # PUT + /goods/(?P<pk>\d+)/ = self.update
    # DELETE + /goods/(?P<pk>\d+)/ = self.destroy
    url(r'^goods/(?P<pk>\d+)/$', SPUModelViewSet.as_view({'get': 'retrieve', 'put': 'update', 'delete':'destroy'})),
    # 可选品牌
    # GET + /goods/brands/simple/
    url(r'^goods/brands/simple/$', BrandSimpleListView.as_view()),
    # 可选一级分类
    # GET + /goods/channel/categories/
    url(r'^goods/channel/categories/$', SPUSimpleCategoryListView.as_view()),
    # 可选二级，三级分类
    # GET + /goods/channel/categories/(?P<pk>\d+)/
    url(r'^goods/channel/categories/(?P<pk>\d+)/$', SPUSimpleCategoryListView.as_view()),

    # 规格表管理
    # GET + /goods/specs/ = self.list
    # POST + /goods/specs/ = self.create
    url(r'^goods/specs/$', SpecModelViewSet.as_view({'get':'list', 'post': 'create'})),
    # GET + /goods/specs/(?P<pk>\d+)/ = self.retrieve
    # PUT + /goods/specs/(?P<pk>\d+)/ = self.update
    # DELETE + /goods/specs/(?P<pk>\d+)/ = self.destroy
    url(r'^goods/specs/(?P<pk>\d+)/$', SpecModelViewSet.as_view({'get':'retrieve', 'put':'update', 'delete':'destroy'})),


    # 选项管理
    url(r'^specs/options/$', OptionModelViewSet.as_view({'get':'list', 'post':'create'})),
    url(r'^specs/options/(?P<pk>\d+)/$', OptionModelViewSet.as_view({'get':'retrieve', 'put':'update', 'delete':'destroy'})),
    # 新增选项可选规格
    url(r'goods/specs/simple/$', SpecSimpleListView.as_view()),

    # 图片管理
    url(r'^skus/images/$', ImageModelViewSet.as_view({
        'get': 'list',
        'post': 'create'
    })),
    url(r'^skus/images/(?P<pk>\d+)/$', ImageModelViewSet.as_view({
        'get': 'retrieve',
        'put': 'update',
        'delete': 'destroy'
    })),

    # 新建图片可选sku
    url(r'^skus/simple/$', SKUSimpleListView.as_view()),

    # 订单管理
    # 序列化返回订单列表数据
    url(r'^orders/$', OrderModelViewSet.as_view({'get':'list'})),
    # 序列化返回订单详情数据
    url(r'^orders/(?P<pk>\d+)/$', OrderModelViewSet.as_view({'get':'retrieve'})),
    # 部分更新订单状态
    url(r'^orders/(?P<pk>\d+)/status/$', OrderModelViewSet.as_view({'patch':'partial_update'})),


    # 权限管理
    url(r'^permission/perms/$', PermModelViewSet.as_view({'get':'list', 'post':'create'})),
    url(r'^permission/perms/(?P<pk>\d+)/$', PermModelViewSet.as_view({'get':'retrieve', 'put':'update', 'delete':'destroy'})),
    # 新建权限可选类型
    url(r'^permission/content_types/$', ContentTypeListView.as_view()),


    # 分组管理
    url(r'^permission/groups/$', GroupViewSet.as_view({"get": 'list', 'post':'create'})),
    url(r'^permission/groups/(?P<pk>\d+)/$', GroupViewSet.as_view({
        'get':"retrieve",
        'put':'update',
        'delete':'destroy'
    })),
    # 新增分组可选权限
    url(r'^permission/simple/$', GroupPermSimpleListView.as_view()),


    # 管理员管理
    url(r'^permission/admins/$', AdminViewSet.as_view({'get':'list', 'post':'create'})),
    url(r'^permission/admins/(?P<pk>\d+)/$', AdminViewSet.as_view({
        'get':'retrieve',
        'put':'update',
        'delete':'destroy'
    })),
    # 新建用户可选分组
    url(r'^permission/groups/simple/$', AdminGroupSimpleListView.as_view()),
]












